#ifndef SSERVER_H
#define SSERVER_H

#include "Socket.h"
#include "EpollHandle.h"
#include "threadpool/CThreadManage.h"



class SServer:public EPollObserver, public IObserver, public ESeviceObserver
{
public:
    enum SocketStatus
    {
        NOT_CONNECTED,
        CONNECTING,
        CONNECTED
    };
private:
    SServer();
    ~SServer(void);
public:
    static SServer* GetInstance();
    int init(int port);
    void doCirculate();

    int Send(const char* data, int len);
    void SetStatus(SocketStatus status);
    void OnHandleData(int, int);
    void OnSeviceCallback(int a, int b);
    void RevData(const int fd, const unsigned short& nOpcode, const char* pDataBuffer, unsigned short nDataSize);

    void sendAll(const int peerfd,const unsigned short &nOpcode, const char *pDataBuffer, unsigned short nDataSize);

private:

    SocketStatus mStatus;
    int listener;
    static class SServer* mInstance;
    Socket *mSocket;
    EpollHandle *mEpoll;
    CThreadManage *mThreadmanager;
    
};

#endif // SServer_H
